#!/bin/bash

NAME=redis-server
PORT=6379
PASSWORD=111111
TAG=6.2.7-alpine

while getopts "n:p:a:t:" opt; do
  case $opt in
    n)
        NAME=$OPTARG
        ;;
    p)
        PORT=$OPTARG
        ;;
    a)
        PASSWORD=$OPTARG
        ;;
    t)
        TAG=$OPTARG
        ;;
    \?)
        echo "invalid arg"
        exit 1
        ;;
  esac
done

docker run \
--restart always \
--name ${NAME} \
--platform linux/amd64 \
-p ${PORT}:6379 \
-v ${PWD}/data:/data \
-d \
redis:${TAG} \
redis-server --requirepass ${PASSWORD}